{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Load Local Area Unemployment \n",
    "This data comes from the BLS. The link is https://www.bls.gov/lau/. These data were accessed on 06/04/2020"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load Data\n",
    "df = pd.read_csv('https://www.bls.gov/web/metro/laucntycur14.txt',sep='|',skiprows=6,header=None)\n",
    "df.columns = ['area_code','state_fips','county_fips','name','date','lf','emp','unemp','ur']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Get rid of preliminary tag \n",
    "df.date = df.date.str.replace(' ','').str.replace('\\\\(p\\\\)','')\n",
    "df = df[df.date.notnull()]\n",
    "\n",
    "# Fix Dates\n",
    "df.date = pd.to_datetime(df.date,format = '%b-%y')\n",
    "\n",
    "# Small DS\n",
    "df.drop(['area_code','name'],axis=1,inplace=True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Save\n",
    "df.to_csv('../../data/bls/lau.csv',index=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3-final"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}